home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
cmln0586.arc
/
FILLING2.LTG
< prev
next >
Wrap
Text File
|
1986-04-06
|
896b
|
34 lines
Listing 2
The simplest seed filling algorithm.
procedure Fill(x,y,NewColor: Integer);
var
EraseColor: Integer;
procedure RecursiveFill(x,y: Integer);
begin {of procedure RecursiveFill}
if PD(x,y) = EraseColor {if point needs filling...}
then
begin
DP(x,y,NewColor); {fill it}
RecursiveFill(x-1,y); {call fill algorithm with neighbors}
RecursiveFill(x+1,y);
RecursiveFill(x,y-1);
RecursiveFill(x,y+1);
end;
end; {of procedure RecursiveFill}
begin {of procedure Fill}
EraseColor := PD(x,y); {record color of seed point}
if EraseColor = NewColor then exit; {already done}
if EraseColor = -1 then exit; {seed point is off screen}
RecursiveFill(x,y);
end; {of procedure Fill}